package com.databasedesign.controller;

import com.databasedesign.pojo.dto.Result;
import com.databasedesign.service.DormitoryLiveinService;
import com.databasedesign.service.DormitoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping
@CrossOrigin
public class DormitoryLiveinController {
    @Autowired
    private DormitoryService dormitoryService;

    @Autowired
    private DormitoryLiveinService dormitoryLiveinService;

    /**
     * 测试接口，查询全部宿舍
     * @return
     */
    @GetMapping("test2")
    public Result GetDor(){
        List list = new ArrayList();
        list = dormitoryService.GetAll();
        return new Result(200,"查宿舍",list);
    }

    /**
     * 分配宿舍号给新生，向宿舍入住表导入数据
     * @return
     */
    @GetMapping("dormitoryLiveIn/checkIn")
    public Result InsertGirl(){
        dormitoryLiveinService.InsertDormitoryLivein();
        return new Result().ok("分配完成");
    }
}
